//1.初始化flash控件的选择功能
function flashInit() {
    var pc = initProcCommand();//alert(pc[0].quality)
   thisMovie("hb_459x452_llx").sendToActionScript(pc);//对应flash 加载代码段中的 id(ie:hb_459x452_llx_ob,非ie:hb_459x452_llx_em)
    // return JSON.stringify(pc);
}
function getCookie(){
	return "2176FF22EB231E691C3F0C4A25FF77994CE1051A9A6F5214";//"E976462697DE44B770471F3418175909";
}
//2.上传前设置上传命令
function initProcCommand(){
	var commands = new Array("-quality 80 -newName 'logo'");
				
	//var commands = new Array("-quality 80 -resize '1600x1600>'"
		//,"-quality 80 -resize '100x100^>' -gravity Center -crop 100x100+0+0 +repage"
		//,"-quality 80 -resize '200x200^>' -gravity Center -crop 200x200+0+0 +repage -waterMark 1"
		//,"-quality 80 -resize '650x650>' -waterMark 1"
		//,"-quality 80 -resize '500x440>' -waterMark 1"
		//)
				
	var pc = new Array();
	for(var i = 0; i < commands.length;i++){
		var _cs = commands[i].split("-");
		var m; //new Object();
		var ms = new Object();
		for(var k = 0; k < _cs.length;k++){
			var c = trim(_cs[k]);
			if(c.length==0){
				continue;
		    }
		    c = c.replace(/\s\+/g, "+" ).split(" ");
			m = new Object();    
			var v = "";
			for(var j = 1; j < c.length;j++){
				v += " "+((c[j] || "").replace( /'(\d+x\d+)([>\\^!<]{0,4})'/g, "$1,$2" ).replace( /[x\\+]/g, "," ).replace( /'/g, "" ));
			}
		    ms[c[0]] = trim(v);
		}
		pc.push(ms);//alert(i)
	}		
	return pc; 
}
function upcAfter(_obj){
	alert("upcAfter:--"+JSON.stringify(_obj));
}
function saveDone(_obj){
	alert("saveDone:--"+JSON.stringify(_obj));
}

//3.判断浏览器 解决chrome兼容性问题
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        if(window[movieName+"_ob"]){
            return window[movieName+"_ob"];
        }else{
            return document[movieName+"_ob"];
        };
    } else {
        if(document[movieName+"_em"]){
            return document[movieName+"_em"];
        }else{
            return document[movieName];
        };
    }
}
/*function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return document.getElementById(movieName);
   	 //return window[movieName];
    } else {
        return document[movieName];
    }
}*/

//对字符串进行处理
function trim(text) {
	return (text || "").replace( /^\s+|\s+$/g, "" );
}